package com.guigu.www.denghao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.guigu.www.denghao.service.DHRoleMenuService;
import com.guigu.www.mapper.RoleMenuMapper;
import com.guigu.www.pojo.RoleMenu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DHRoleMenuServiceImpl implements DHRoleMenuService {

    @Autowired
    private RoleMenuMapper roleMenuMapper;

    @Override
    public void up(Integer[] menus, Integer roleId) {
        roleMenuMapper.delete(new QueryWrapper<RoleMenu>().eq("role_id",roleId));
        for (Integer menu : menus) {
            RoleMenu roleMenu = new RoleMenu(null,roleId,menu);
            roleMenuMapper.insert(roleMenu);
        }
    }
}
